<!DOCTYPE html>
<html>
	<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />
	<meta name="format-detection" content="telephone=no" />
    <meta name="format-detection" content="email=no" />
    <meta name="format-detection" content="address=no">
	
	<title>瑞州支付</title>
	<link rel="stylesheet"  href="./css/common.css" />
	<link rel="stylesheet"  href="./css/down.css" />
	<script type="text/javascript" src="./js/pay.js"></script>
	<script type="text/javascript" src="./js/order_demo.js"></script>
	<script type="text/javascript">
		window.onload = function(){
			
			var ch = document.body.clientHeight;
	        var at = document.body.scrollHeight;
	        if(ch!=at){
				$("down_tool").style.display 		= "none";
				$("top_tool").style.display 		= "none";
		    }
	      
	        window.onscroll = function(){
	        	
	       		if(reachBottom()){
	       			$("down_tool").style.display 		= "none";
		        }else{
		        	$("down_tool").style.display 		= "block";
			    }
			    if(reachTop()){
			    	$("top_tool").style.display 		= "none";
				}else{
					$("top_tool").style.display 		= "block";
				}
	        }
	
			/**获取订单信息*/
			//var orderInfo =order;
			var orderInfo =get_order_info();
			
			/**填充表单*/
			$('MerId').value 		= orderInfo.MerId;
			$('OrderId').value 		= orderInfo.OrderId;
			$('ProdName').value 	= orderInfo.ProdName;
			$('EncString').value 	= orderInfo.EncString;
			$('NoticeUrl').value 	= orderInfo.NoticeUrl;
			$('AccountNo').value 	= orderInfo.AccountNo;
			$('Price').value 		= orderInfo.Price;
			$("ItemName").value		= orderInfo.ItemName;
			$("Note").value			= orderInfo.Note;
			/**填充显示界面*/
			$("item_name").innerHTML		= orderInfo.ItemName;
			$("exchange_rate").innerHTML	= orderInfo.ExchangeRate;
			$("currency").innerHTML			= orderInfo.ItemName;
			$("currency_money").innerHTML 	= orderInfo.ItemName;
	
			
			/**选择是道具购买界面还是充值界面*/
			if(orderInfo.Price!=-1){
				$("item_info").style.display 		= "block";
				$("exchange_info").style.display 	= "none";
				$("item_price").innerHTML 			= orderInfo.Price;
			}else{
				$("exchange_info").style.display 	= "block";
				$("charge_info").style.display 		= "block";
				$("item_info").style.display 		= "none";
				exchange_currency(10,orderInfo.ExchangeRate);//默认选中充值10元,所以给个10元的默认值
			}

			/**金额操作*/
			var labels 	=document.getElementsByName("money_label");
			//设置默认卡
			var appropriate_card 	=0;
			var money_radio 		=document.getElementsByName("money");
			for(i=0;i<money_radio.length;i++){
				if(parseInt(money_radio[i].value)>=parseInt(orderInfo.Price)){
					money_radio[i].setAttribute('checked','checked');
					appropriate_card = parseInt(money_radio[i].value);
					labels[i].setAttribute('class','jelabel ui-bg');
					break;
				}else{

				}
			}
			
			var price	=10;
			for(i=0;i<labels.length;i++){
				labels[i].onclick = function(){
					if(this.attributes['class'].value != "jelabel ui-bg"){
						for(j=0;j<labels.length;j++){
							labels[j].setAttribute('class','jelabel');
						}
						this.setAttribute('class','jelabel ui-bg');
						
						price = siblings(this)[0].attributes['value'].value;
						if(orderInfo.Price==-1){
							exchange_currency(price,orderInfo.ExchangeRate);
						}
					//	check_money(orderInfo.Price, price);
					}
						check_appropriate_card(appropriate_card,price);
				}
			}

			$("card_no").onkeyup = function(){
				if($("card_no").value.replace(/(^\s*)|(\s*$)/g, "")!=""){
					closepop('card_popup');
				}
				if(!/\D/.test($("card_no").value)){
					closepop('wrongCardNo_popup');
				}
				if($("card_no").value.length == 17){
					closepop('shortCardNo_popup');
				}
				
			}
			$("card_password").onkeyup = function(){
				if(!/\D/.test($("card_password").value)){
					closepop('wrongCardPs_popup');
				}
				if($("card_password").value.replace(/(^\s*)|(\s*$)/g, "")!=""){
					closepop('password_popup');
				}
				if($("card_password").value.length == 18){
					closepop('shortCardPs_popup');
				}
				
			}
			

			
			$("submit").onclick = function(){
				var card_price = 0;
				var moneyradios = document.getElementsByName('money');
				for ( var i = 0; i < moneyradios.length; i++) {
					if(moneyradios[i].checked){
						card_price = moneyradios[i].value;
						
					}
				}
				$("Price").value = card_price;
				if(orderInfo.Price != -1){
					$("Price").value = orderInfo.Price;
					if(parseInt(card_price)<parseInt(orderInfo.Price)){
						$("errPrice").innerHTML = "充值卡的面额不能小于"+orderInfo.Price+"元";
						openpop("errorPrice_popup");
						setTimeout("closepop('errorPrice_popup')",2000);
						return false;
					}
				}
				
				if($("card_no").value.replace(/(^\s*)|(\s*$)/g, "")==""){
					openpop("card_popup");
					//setTimeout("closepop('card_popup')",2000);
					return false;
				}
				if(/\D/.test($("card_no").value)){
					openpop("wrongCardNo_popup");
					//setTimeout("closepop('wrongCardNo_popup')",2000);
					return false;
				}
				if(/\D/.test($("card_password").value)){
					openpop("wrongCardPs_popup");
					//setTimeout("closepop('wrongCardPs_popup')",2000);
					return false;
				}
				if($("card_password").value.replace(/(^\s*)|(\s*$)/g, "")==""){
					openpop("password_popup");
					//setTimeout("closepop('password_popup')",2000);
					return false;
				}
				if($("card_no").value.length != 17){
					openpop("shortCardNo_popup");
					//setTimeout("closepop('shortCardNo_popup')",2000);
					return false;
				}
				if($("card_password").value.length != 18){
					openpop("shortCardPs_popup");
					//setTimeout("closepop('shortCardPs_popup')",2000);
					return false;
				}
			}
			
		};		
	</script>
	</head>
	<body>
	<div id="#top"></div>
		<div class="ui-header ui-bg">
			<span class="back h_btn"><a class="ui-a" href="javascript:window.history.back();">返回</a></span>
			<h1>天天互娱 - 移动充值卡充值</h1>
			<span class="close h_btn"><a class="ui-a" href="javascript:window.JsGameCenter.closeWebView();">关闭</a></span>
		</div>
		<div class="ui-content">
			<div class="main_content">
				<form id="form" action="http://210.83.86.176/mpay/index.php/pay" method="post">
					<div id="exchange_info" style="display:none;">
						<p>请选择充值面额(<span class="red">1</span>元 =<span class="red" id="exchange_rate">10</span>个<span id="currency">元宝</span>):</p>
						<br />
					</div>
					<div class="choosemoney">
						<div id="item_info">
							您购买了 <span id="item_name" class="red"></span> ,总计 <span id="item_price" class="red" ></span> 元
						<br/><br/>
						选择面额：<br/><br/>
						</div>
						<ul>
							<li><input class="je" type="radio" checked="checked" name="money" value="10" id="c1"><label name="money_label" for="c1" class="jelabel">10元</label></li>
							<li><input class="je" type="radio"  name="money" value="20" id="c2"><label name="money_label" for="c2" class="jelabel">20元</label></li>
							<li><input class="je" type="radio" name="money" value="30" id="c3"><label name="money_label" for="c3" class="jelabel">30元</label></li>
							<li><input class="je" type="radio"  name="money" value="50" id="c4"><label name="money_label" for="c4" class="jelabel">50元</label></li>
							<li><input class="je" type="radio" name="money" value="100" id="c5"><label name="money_label" for="c5" class="jelabel">100元</label></li>
							<li><input class="je" type="radio" name="money" value="300" id="c7"><label name="money_label" for="c7" class="jelabel">300元</label></li>
							<li><input class="je" type="radio"  name="money" value="500" id="c8"><label name="money_label" for="c8" class="jelabel">500元</label></li>
						</ul>
					</div>
					<div id="less_tishi"  style="display:none;" class="red"><br />你选择的面额低于待支付金额，无法购买该商品<br /></div>
					<div id="card_tishi"  style="display:none;" class="warn"><br />请选择合适的金额<br /></div>
					
					<div id="charge_info" style="display:none;">
						您将充值：<span id="money_num" class="red"></span>元(<span id="exchange_money" class="red"></span>个<span id="currency_money" ></span>)
					</div>
					<div class="bot">
						<p><label for="card_no">充值卡卡号(17位):</label></p>
    					<p><input type="number" name="card_no" id="card_no"   value="" placeholder="充值卡卡号(17位)"  class="ui-input" /></p>
    					<p><label for="card_password">充值卡密码(18位):</label></p>
    					<p><input type="number" class="ui-input"  name="card_password" id="card_password"   value="" placeholder="充值卡密码(18位)" /></p>
    					<br />
    					
    					<div class="pop" id="pop" style="display:none;">
							<div class="warn_tip">
								<p>订单信息获取失败</p>
							</div>
						</div>
						<div style="display:none;" id="carddeno_popup" >
							<div class="warn_tip">
					          <p>请选择您的充值卡面额</p>
				            </div>
						</div>
						<div style="display:none;" id="card_popup" >
							<div class="warn_tip">
					          <p>请输入您的充值卡号</p>
							</div>
						</div>
						<div style="display:none;" id="password_popup" >
				        	<div class="warn_tip">	
					          <p>请输入您的充值卡密码</p>
							</div>
						</div>
						<div style="display:none;" id="wrongOrder_popup" >
							<div class="warn_tip">
					          <p>订单信息获取失败</p>
							</div>
						</div>
						<div style="display:none;" id="wrongCardNo_popup" >
							<div class="warn_tip">
					          <p>充值卡卡号只能是数字</p>
							</div>
						</div>
						<div style="display:none;" id="wrongCardPs_popup" >
							<div class="warn_tip">
					          <p>充值卡密码只能是数字</p>
							</div>
						</div>
						<div style="display:none;" id="shortCardNo_popup" >
							<div class="warn_tip">
					          <p>充值卡卡号必须是17位</p>
							</div>
						</div>
						<div style="display:none;" id="shortCardPs_popup" >
							<div class="warn_tip">
					          <p>充值卡密码必须是18位</p>
							</div>
						</div>
						<div style="display:none;" id="errorPrice_popup" >
							<div class="warn_tip">
					          <p id="errPrice"></p>
							</div>
						</div>
						<p><input type="button" value="立即充值" id="submit" class="ui-bg ui-btn" /></p>
						<input type="hidden" id="MerId"  		name="MerId" 		value="" />
						<input type="hidden" id="OrderId"    	name="OrderId" 		value="" />
						<input type="hidden" id="ProdName"    	name="ProdName" 	value="" />
						<input type="hidden" id="EncString"    	name="EncString" 	value="" />
						<input type="hidden" id="NoticeUrl"    	name="NoticeUrl" 	value="" />
						<input type="hidden" id="PayType"    	name="PayType" 		value="yeepay" />
						<input type="hidden" id="AccountNo"    	name="AccountNo" 	value="" />
						<input type="hidden" id="ItemName"  	name="ItemName" 	value="" />
						<input type="hidden" id="Note"  		name="Note"			value="" />
						<input type="hidden" id="Price"    		name="Price" 		value="" />
						<input type="hidden"			   		name="t_card_type" 	value="SZX" />
						<br />
						<div class="notice">
							<p class="intro">温馨提示:</p>
							<p class="intro">1.请务必使用与您所选面额相同的充值卡进行支付，否则您将承担因此而引起的交易失败或者交易金额丢失所造成的损失.</p>
							<p class="intro">2.支持中国移动全国通用充值卡,以及浙江,福建,广东,辽宁的移动本地充值卡.</p>
							<p class="intro">3.由于网络原因,充值到账可能有一定的延迟,请耐心等待.</p>
							<p class="intro">4.如在支付过程中出现任何问题,请拨打瑞州客服热线:4006-61-00-61</p>
						</div>
					</div>
				</form>
			</div>
		</div>
		
		<div  class="back-to" id="top_tool" >
			<a title="back_top"  onclick="sc_top()"  class="move_tool move_top">
			back_top
			</a>
		</div>
		<div  class="back-to" id="down_tool">
			<a title="move_down"  onclick="sc_bottom()" class="move_tool move_down">
			move_down
			</a>
		</div>
	</body>
</html>